package com.jit.app.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.alibaba.fastjson.JSON;

import java.util.Map;

public class LoginUtils {
    public static final String LOGIN_SP_NAME = "login";
    public static final String LOGIN_USER_KEY = "login_user";

    public static String isLogin(Context context){
        SharedPreferences sharedPreferences = context.getSharedPreferences(LOGIN_SP_NAME, Context.MODE_PRIVATE);
        String user_info = sharedPreferences.getString(LOGIN_USER_KEY, null);
        return user_info;
    }

    public static void saveLoginInfo(Context context, Map userInfo){

        SharedPreferences sharedPreferences = context.getSharedPreferences(LOGIN_SP_NAME, Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putString(LOGIN_USER_KEY, JSON.toJSONString(userInfo));
        edit.commit();
    }

}
